package mof.gov.dmdc.view.searchitem;

public class AdvancedSearchCriteria extends SearchCriteria {
    public AdvancedSearchCriteria(String totalValue, String attrValue, String operator, boolean andConjunction, boolean notConjunction) {
        super(attrValue);
        this.totalValue = totalValue;
        this.operator = operator;
        this.andConjunction = andConjunction;
        this.notConjunction = notConjunction;
    }

    private String totalValue; //totalValue = "attrName" + "attrType" + "lovName" (attrName;attrType;lovName)
    private String operator;
    private boolean andConjunction;
    private boolean notConjunction;

    public void setOperator(String operator) {
        this.operator = operator;
    }

    public String getOperator() {
        return operator;
    }

    public void setAndConjunction(boolean andConjunction) {
        this.andConjunction = andConjunction;
    }

    public boolean isAndConjunction() {
        return andConjunction;
    }

    public void setNotConjunction(boolean notConjunction) {
        this.notConjunction = notConjunction;
    }

    public boolean isNotConjunction() {
        return notConjunction;
    }

    public void setTotalValue(String totalValue) {
        this.totalValue = totalValue;
    }

    public String getTotalValue() {
        return totalValue;
    }

    public String getAttrName() {
        String[] variableList = totalValue.split(";");
        try {
            attrName = variableList[0];
        } catch (Exception e) {
            attrName = "";
        }
        return attrName;
    }

    public String getAttrType() {
        String[] variableList = totalValue.split(";");
        try {
            attrType = variableList[1];
        } catch (Exception e) {
            attrType = "";
        }
        return attrType;
    }

    public String getLovName() {
        String[] variableList = totalValue.split(";");
        try {
            lovName = variableList[2];
        } catch (Exception e) {
            lovName = "";
        }
        return lovName;
    }

    public int getViewType() {
        if (getAttrType().equalsIgnoreCase("number")) {
            viewType = 1;
        } else {
            if (getAttrType().equalsIgnoreCase("date")) {
                viewType = 2;
            } else {
                if (getAttrType().equalsIgnoreCase("varchar2") && !getLovName().isEmpty()) {
                    viewType = 3;
                } else {
                    viewType = 4;
                }
            }
        }
        return viewType;
    }
}
